package univers;

import univers.EspaceAffine.Point;
import univers.EspaceAffine.Vecteur;
import univers.EspaceAffine.Z;
import static univers.EspaceAffine.Z.*;

public class Avatar {

    public Point position;
    EspaceAffine domaine;

    Avatar(EspaceAffine domaine) {
        this.domaine = domaine;
        position = EspaceAffine.Origine;
    }

    boolean vers(Vecteur direction) {

        position.X = position.X.plus(direction.u);
        position.Y = position.Y.plus(direction.v);
        return isALimit();
    }

    boolean vers(Z pas, Vecteur direction) {
        position.X = position.X.plus(pas.times(direction.u));
        position.Y = position.Y.plus(pas.times(direction.v));
        return isALimit();
    }

    private boolean isALimit() {
        return (position.X.inf(minX)) || (position.X.sup(maxX)) || (position.Y.inf(minY)) || (position.Y.sup(maxY));

    }
}
